# Maintainer: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=buildah
pkgver=1.30.0
pkgrel=1
pkgdesc="A tool which facilitates building OCI images"
arch=(loong64 x86_64)
url="https://github.com/containers/buildah"
license=(Apache)
depends=(crun skopeo slirp4netns)
makedepends=(go git bash-bats btrfs-progs device-mapper gpgme libassuan
             bzip2 go-md2man runc skopeo systemd)
options=(!lto !debug)
_commit=04965f1198104afafd22197a479bd15c9b43148e	#refs/tags/v1.30.0
source=(git+https://github.com/containers/buildah.git#commit=$_commit)
md5sums=('SKIP')

pkgver() {
  cd buildah
  git describe --tags | sed 's/^[vV]//;s/-/+/g'
}

build() {
  cd $pkgname
  export GOFLAGS="-buildmode=pie -trimpath"
  export CGO_LDFLAGS="${LDFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  make PREFIX=/usr BUILDTAGS="containers_image_ostree_stub seccomp"
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" PREFIX=usr install install.completions
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
